package c.d.a.a.i;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.RectF;
import c.d.a.a.b.i;
import c.d.a.a.b.i.a;
import c.d.a.a.b.i.b;
import c.d.a.a.j.f;
import c.d.a.a.j.g;
import c.d.a.a.j.h;
import java.util.List;
import java.util.Objects;

/* compiled from: YAxisRenderer */
public class m extends a {
    public i h;
    public Paint i;
    public Path j = new Path();
    public RectF k = new RectF();
    public float[] l = new float[2];
    public Path m = new Path();
    public RectF n = new RectF();
    public Path o = new Path();
    public float[] p = new float[2];
    public RectF q = new RectF();

    public m(h hVar, i iVar, f fVar) {
        super(hVar, fVar, iVar);
        this.h = iVar;
        if (this.a != null) {
            this.e.setColor(-16777216);
            this.e.setTextSize(g.d(10.0f));
            Paint paint = new Paint(1);
            this.i = paint;
            paint.setColor(-7829368);
            this.i.setStrokeWidth(1.0f);
            this.i.setStyle(Style.STROKE);
        }
    }

    public void c(Canvas canvas, float f, float[] fArr, float f2) {
        i iVar = this.h;
        int i = iVar.A ^ 1;
        boolean z = iVar.B;
        int i2 = iVar.m;
        if (!z) {
            i2--;
        }
        while (i < i2) {
            canvas.drawText(this.h.b(i), f, fArr[(i * 2) + 1] + f2, this.e);
            i++;
        }
    }

    public RectF d() {
        this.k.set(this.a.b);
        this.k.inset(0.0f, -this.b.h);
        return this.k;
    }

    public float[] e() {
        int length = this.l.length;
        int i = this.h.m;
        if (length != i * 2) {
            this.l = new float[(i * 2)];
        }
        float[] fArr = this.l;
        for (i = 0; i < fArr.length; i += 2) {
            fArr[i + 1] = this.h.k[i / 2];
        }
        this.c.f(fArr);
        return fArr;
    }

    public Path f(Path path, int i, float[] fArr) {
        i++;
        path.moveTo(this.a.b.left, fArr[i]);
        path.lineTo(this.a.b.right, fArr[i]);
        return path;
    }

    public void g(Canvas canvas) {
        b bVar = b.OUTSIDE_CHART;
        i iVar = this.h;
        if (iVar.a && iVar.s) {
            float f;
            float[] e = e();
            Paint paint = this.e;
            Objects.requireNonNull(this.h);
            paint.setTypeface(null);
            this.e.setTextSize(this.h.d);
            this.e.setColor(this.h.e);
            float f2 = this.h.b;
            float a = ((float) g.a(this.e, "A")) / 2.5f;
            i iVar2 = this.h;
            a += iVar2.c;
            a aVar = iVar2.H;
            b bVar2 = iVar2.G;
            if (aVar == a.LEFT) {
                if (bVar2 == bVar) {
                    this.e.setTextAlign(Align.RIGHT);
                    f = this.a.b.left;
                    f -= f2;
                    c(canvas, f, e, a);
                }
                this.e.setTextAlign(Align.LEFT);
                f = this.a.b.left;
            } else if (bVar2 == bVar) {
                this.e.setTextAlign(Align.LEFT);
                f = this.a.b.right;
            } else {
                this.e.setTextAlign(Align.RIGHT);
                f = this.a.b.right;
                f -= f2;
                c(canvas, f, e, a);
            }
            f += f2;
            c(canvas, f, e, a);
        }
    }

    public void h(Canvas canvas) {
        i iVar = this.h;
        if (iVar.a && iVar.r) {
            this.f.setColor(iVar.i);
            this.f.setStrokeWidth(this.h.j);
            RectF rectF;
            float f;
            if (this.h.H == a.LEFT) {
                rectF = this.a.b;
                f = rectF.left;
                canvas.drawLine(f, rectF.top, f, rectF.bottom, this.f);
                return;
            }
            rectF = this.a.b;
            f = rectF.right;
            canvas.drawLine(f, rectF.top, f, rectF.bottom, this.f);
        }
    }

    public void i(Canvas canvas) {
        i iVar = this.h;
        if (iVar.a) {
            if (iVar.q) {
                int save = canvas.save();
                canvas.clipRect(d());
                float[] e = e();
                this.d.setColor(this.h.g);
                this.d.setStrokeWidth(this.h.h);
                Paint paint = this.d;
                Objects.requireNonNull(this.h);
                paint.setPathEffect(null);
                Path path = this.j;
                path.reset();
                for (int i = 0; i < e.length; i += 2) {
                    canvas.drawPath(f(path, i, e), this.d);
                    path.reset();
                }
                canvas.restoreToCount(save);
            }
            Objects.requireNonNull(this.h);
        }
    }

    public void j(Canvas canvas) {
        List list = this.h.t;
        if (list != null && list.size() > 0) {
            float[] fArr = this.p;
            fArr[0] = 0.0f;
            fArr[1] = 0.0f;
            Path path = this.o;
            path.reset();
            for (int i = 0; i < list.size(); i++) {
                if (((c.d.a.a.b.g) list.get(i)).a) {
                    int save = canvas.save();
                    this.q.set(this.a.b);
                    this.q.inset(0.0f, -0.0f);
                    canvas.clipRect(this.q);
                    this.g.setStyle(Style.STROKE);
                    this.g.setColor(0);
                    this.g.setStrokeWidth(0.0f);
                    this.g.setPathEffect(null);
                    fArr[1] = 0.0f;
                    this.c.f(fArr);
                    path.moveTo(this.a.b.left, fArr[1]);
                    path.lineTo(this.a.b.right, fArr[1]);
                    canvas.drawPath(path, this.g);
                    path.reset();
                    canvas.restoreToCount(save);
                }
            }
        }
    }
}
